#include "SubsystemExplosionsBase.h"
#include "Components/ComponentPlayer.h"
#include "Terrain/Terrain.h"
#include "Managers/BlocksManager.h"

namespace PocketSurvival
{
    bool SubsystemExplosionsBase::tryExplodeBlock(int32_t x, int32_t y, int32_t z, int32_t value)
    {
        int32_t contents = Terrain::ExtractContents(value);
        Block *block = GameSingleton::blocksManager->blocks[contents];
        float explosionPressure = block->getExplosionPressure(value);
        bool explosionIncendiary = block->getExplosionIncendiary(value);
        if(explosionPressure > 0.0f)
        {
            addExplosion(x, y, z, explosionPressure, explosionIncendiary);
            return true;
        }
        return false;
    }

    void SubsystemExplosionsBase::addExplosion(int32_t x, int32_t y, int32_t z, float pressure, bool isIncendiary)
    {
    }

    static const std::string subsystemName = "Explosions";
    const std::string& SubsystemExplosionsBase::getName() const
    {
        return subsystemName;
    }
    void SubsystemExplosionsBase::update(float dt)
    {
    }

    void SubsystemExplosionsBase::load(const nlohmann::json &json){}
    void SubsystemExplosionsBase::save(nlohmann::json &json){}
    void SubsystemExplosionsBase::saveToMsgJson(nlohmann::json &jsonData){}
}